<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>首页</title>
</head>
<body>

<h1>首页</h1>

<div>欢迎</div>

</body>
</html>

<script>

    //获取地址栏路径参数对象
    function getQueryParam(name) {
        const queryString = window.location.search;

        console.log(queryString)
        const params = new URLSearchParams(queryString);
        console.log(params)

        return params.get(name);
    }

    //页面加载完成后执行
    window.onload = function () {
        const param = getQueryParam('username');
        console.log(param);
        alert(param);
    }


</script>